﻿Imports LinhKienMayTinh.CommonMethods

Public Class ProductDetailControl
    Inherits System.Web.UI.UserControl

    Protected dsSource As DataSet
    Public Property DataSource() As DataSet
        Get
            Return dsSource
        End Get
        Set(ByVal value As DataSet)
            dsSource = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim xPrice As String
        Try
            If IsNothing(DataSource) = False Then
                With DataSource.Tables(0).Rows(0)
                    Me.lbName.Text = Nz(.Item("PRODUCT_NAME"), "")
                    Me.imgImage.ImageUrl = ResolveUrl(Nz(.Item("IMG_LINK"), ""))
                    Me.imgImage.AlternateText = Nz(.Item("PRODUCT_NAME"), "")
                    Me.imgImage.ToolTip = Nz(.Item("PRODUCT_NAME"), "")
                    Me.lbCondition.Text = Nz(.Item("CONDITION"), "")
                    Me.lbWarranty.Text = Nz(.Item("WARRANTY"), "")
                    Me.ltSpec.Text = Nz(.Item("SPECIFICATION"), "")
                    Me.ltDescription.Text = Nz(.Item("DESCRIPTION"), "")
                    If IsDBNull(.Item("PRICE")) = False Then
                        xPrice = Replace(Format(CDbl(.Item("PRICE")), "#,##0"), ",", ".")
                        If xPrice = "0" Then
                            xPrice = "CALL"
                        Else
                            xPrice = xPrice & " VNĐ"
                        End If
                        Me.lbPrice.Text = xPrice
                    Else
                        Me.lbPrice.Text = "CALL"
                    End If

                    '' Tạo động meta tag Description và Keywords.
                    Dim meta As HtmlMeta = Page.Header.FindControl("Keywords")
                    If meta IsNot Nothing Then
                        meta.Content = Nz(.Item("PRODUCT_NAME"), "")
                    End If
                End With
            End If
        Catch ex As Exception
            Throw
        End Try
    End Sub

End Class